Add Meson build system for all platforms#11
Add Meson build system for all platforms#11s-celles wants to merge 4 commits intogeogebra:masterfrom
Conversation
|
Be aware that only execution on native desktop (macOS) and Webassembly have been tested (on a very basic example ie 1+1) Some AI thoughts about Meson... Meson Build SystemMeson is a modern, open-source build system designed to be fast, user-friendly, and correct. It generates build files for a backend (typically Ninja), rather than executing builds itself. It's written in Python but produces highly optimized build configurations. Key characteristicsMeson emphasizes speed (both configuration and compilation), a clean and readable syntax (its DSL is deliberately not Turing-complete to keep build definitions simple), and strong out-of-the-box defaults like warning flags, LTO, and unity builds. Why it's particularly interesting for multi-arch cross-compilation (like GIAC)For a project like GIAC — a computer algebra library that needs to compile across many architectures (x86_64, ARM, RISC-V, WebAssembly, etc.) — Meson brings several compelling advantages: First-class cross-compilation support. Unlike autotools or CMake, cross-compilation in Meson isn't an afterthought. You define a simple "cross file" (an INI-like text file) that specifies the target architecture's compiler, linker, system properties (endianness, pointer size, etc.), and any pkg-config paths. Once that file exists, a cross build is invoked with a single flag: Strict separation of build and host. Meson clearly distinguishes between the build machine (where compilation runs) and the host machine (where the binary will run), and optionally the target machine. This makes it natural to handle scenarios where you compile GIAC on an x86_64 workstation but target an embedded ARM board. Reproducible and hermetic builds. Because Meson's language is intentionally limited (no arbitrary shell commands in the build definition), builds are more deterministic. This matters when you're building the same codebase for 5+ architectures and need confidence that differences in output come only from the toolchain, not from build system quirks. Dependency handling. Meson integrates well with pkg-config and wraps (its built-in dependency vendoring system). For GIAC, which depends on GMP, MPFR, and potentially other math libraries, you can define fallback subprojects per architecture without contaminating the main build logic. Fast incremental rebuilds. Since GIAC is a large C++ codebase, the Ninja backend that Meson targets provides excellent incremental build performance — much faster than Make-based systems for large projects with many translation units. Unity builds are natively supported, which can dramatically reduce compile times for large C++ projects like GIAC by combining source files before compilation, reducing redundant header parsing. In short, Meson removes much of the friction traditionally associated with cross-compilation. Where autotools requires deep expertise and CMake toolchain files can become complex and fragile, Meson's cross files are straightforward and self-contained — making it a natural fit for a project like GIAC that aims to be portable across many platforms. Several major and well-known projects have adopted Meson. Here are some notable ones: System-level and foundational projects:
Multimedia:
Libraries and tools:
Language ecosystems:
Other:
The trend is clear: projects that were historically tied to autotools — especially in the Linux/GNOME/Freedesktop ecosystem — have been steadily migrating to Meson. Mesa and QEMU are perhaps the most impressive examples, given their sheer size and complexity, demonstrating that Meson scales well for large, multi-platform, multi-architecture C/C++ codebases — which is exactly the profile GIAC fits into. Meson is fully compatible with Windows. This is actually one of its major strengths compared to autotools (which is notoriously painful on Windows). Specifically, on Windows, Meson supports: Native Windows compilers: MSVC (Visual Studio), Clang-cl, and MinGW/GCC. It automatically detects the available compiler and adapts accordingly. Backends: Ninja (the most common) but also direct generation of Visual Studio projects ( Cross-compilation from/to Windows: you can cross-compile to Windows from Linux (using MinGW), or from Windows to other targets. Installation is straightforward: either via For a project like GIAC, this is a significant advantage: autotools is historically very poorly suited to Windows (you typically need to go through MSYS2/Cygwin, which adds a layer of complexity). With Meson, you can natively target Windows with MSVC without those contortions, while keeping the exact same |
|
@s-celles thanks for working on this. This repository is a shared effort of Bernad Parisse, the maintainer of Giac, who authors the actual code, and the GeoGebra team who keep the build files up-to-date with the goal of providing Giac library for all the platforms that GeoGebra runs on. To make use of your changes GeoGebra team would have to test them, update our build machines to make sure Meson install requirements are met, update the pipeline definition etc., at the moment I don't think we have the capacity to work on that. I can ask Bernard if he sees a use of this PR for non-GeoGebra builds. |
Summary
meson.build,meson_options.txt) as an alternative to CMake/Gradle, supporting all existing target platformscross/) for Android (4 ABIs), iOS (3 variants), Mac Catalyst (2 architectures), Windows (MinGW x86_64), Emscripten WASM, and Linux ARMbuild-all.sh(automated multi-platform build),build-xcframework.sh(iOS xcframework assembly),embed-wasm.sh(WASM base64 post-processing)README-BUILD-WITH-MESON.mdwith build instructions for all targetsValidated Targets
All 13 build targets pass from a macOS host:
libgiac.a,minigiac,libjavagiac.dyliblibgiac.a,libjavagiac.solibgiac.a,libsimpleinterface.alibgiac.a,libsimpleinterface.alibgiac.a,libjavagiac.dllgiacggb.wasm,giac.wasm.jsDesign Decisions
src/jni/prebuilt/for cross-builds, system libraries for native buildsbuild.gradle(authoritative) rather than CMakesrc/jni/jdkHeaders/instead of requiring Java as a Meson project language.gitignore)Test plan
echo '1+1' | ./builddir/minigiacoutputs2./scripts/build-all.shruns all targets with 13/13 passing